package net.thxjj.adminServer.util;


import java.util.Base64;

public class Base64Util {

    /**
     * Base64
     *
     */
    public static String base64Encode(String str) {
        byte[] bytes = str.getBytes();

        //Base64 加密
        String encoded = Base64.getEncoder().encodeToString(bytes);
        System.out.println("Base 64 加密后：" + encoded);

        return encoded;

    }

    /**
     * base64Decode
     * @param enstr
     * @return
     */
    public static String base64Decode(String enstr){
        //Base64 解密
        byte[] decoded = Base64.getDecoder().decode(enstr);

        String decodeStr = new String(decoded);
        System.out.println("Base 64 解密后：" + decodeStr);

        return decodeStr;
    }



}
